﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Routing;
using Castle.Core.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using User.EF.Contracts;
using User.EF.Model;
using User.Global.Contracts.Mail;
using User.Global.Contracts.Membership;
using User.Global.Tests.Helper.MockHelper;
using User.Web.UI.Controllers;
using User.Web.UI.Helper.Messages;

namespace User.Web.UI.Tests.Unit.CommonTests
{
    public class CommonBaseTest
    {
        protected Mock<IDiMembership<Member>> MockMembership { get; set; }

        protected Mock<IAccountMails> MockAccountMails { get; set; }

        protected Mock<IWebQuerySummary> MockWebQuerySummary { get; set; }

        protected AccountController AccountController { get; set; }

        [TestInitialize]
        public void Initialize()
        {
            MockAccountMails = new Mock<IAccountMails>();
            MockMembership = new Mock<IDiMembership<Member>>();
            MockWebQuerySummary = new Mock<IWebQuerySummary>();
            //Wir legen hier den Usernamen und das PW fest welches gemockt werden soll für den Login
            MockMembership.Setup(p => p.Login("squadwuschel", "testname", true)).Returns(true).Verifiable();

            AccountController controller = new AccountController(MockMembership.Object, MockAccountMails.Object, MockWebQuerySummary.Object);
            //Setzten unserer beiden MainProperties für das Logging und die Messageanzeige.
            controller.Logger = new ConsoleLogger();
            controller.AddMessage = new CustomMessage();

            ControllerContext controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);
            controller.ControllerContext = controllerContext;
            AccountController = controller;
        }
    }
}
